package util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Pattern;

public class StringUtils {
	public static SimpleDateFormat dateFormater = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aaa", Locale.ENGLISH);
	public static Date defaultTime = getDefaultFixTime(); 
	
	protected static Date getDefaultFixTime(){
		try {
			defaultTime = dateFormater.parse("1/1/0001 12:00:00 AM");
		} catch (ParseException e) {
			e.printStackTrace();
		}		
		return defaultTime;
	}
	
	public static String firstUpperCase(String word) {
		char fc = word.charAt(0);
		String tmp = word.substring(1).toLowerCase();
		return Character.toUpperCase(fc) + tmp;
	}

	public static String extractFileSuffix(String file) {
		int li = file.lastIndexOf(".");
		if(li == -1) return "";
		return file.substring(li);
	}
	
	public static boolean isNumeric(String str){ 
	    Pattern pattern = Pattern.compile("[0-9]*"); 
	    return pattern.matcher(str).matches();    
	 }
	
	public static String newLine = System.getProperty("line.separator");

	public static void printArray(String[] weights, int count) {
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < count; i++ ){
			sb.append(weights[i] + " ");
		}
		System.out.println(sb.toString());
	}
}
